<template>
  <div>
    <el-collapse-transition>
      <el-card v-if="searchShow" shadow="never" :body-style="{ padding: '20px 10px 0px 20px' }">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
          <!--文本框-->
          <el-form-item>
            <el-input v-model="dataForm.appId" :placeholder="$t('msgWechatTemplateRel.appId')" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="getDataList()">{{ $t('query') }}</el-button>
            <el-button @click="searchReset()">{{ $t('reset') }}</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </el-collapse-transition>
    <el-card shadow="never" class="aui-card--fill" :style="searchShow?'margin-top: 10px;':''">
      <div class="crud__menu">
        <div class="crud__left">
          <el-form :inline="true">
            <el-form-item>
              <el-button v-if="$hasPermission('msg:msgWechatTemplateRel:save')" type="primary"
                @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
            </el-form-item>
            <el-form-item>
              <el-button v-if="$hasPermission('msg:msgWechatTemplateRel:delete')" type="danger" @click="deleteHandle()">
                {{ $t('deleteBatch') }}</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="crud__right">
          <el-button-group>
            <el-button icon="el-icon-search" @click="searchShowHandle()"></el-button>
            <el-button icon="el-icon-refresh" @click="getDataList()"></el-button>
            <el-button icon="el-icon-download" @click="exportHandle()"></el-button>
          </el-button-group>
        </div>
      </div>
      <div class="mod-msg__msgWechatTemplateRel">
        <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
          style="width: 100%;">
          <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
          <el-table-column prop="appId" :label="$t('msgWechatTemplateRel.appId')" :show-overflow-tooltip="true"
            header-align="center" align="center">
          </el-table-column>
          <el-table-column prop="templateId" :label="$t('msgWechatTemplateRel.templateId')"
            :show-overflow-tooltip="true" header-align="center" align="center">
          </el-table-column>
          <el-table-column prop="templateIdWx" :label="$t('msgWechatTemplateRel.templateIdWx')"
            :show-overflow-tooltip="true" header-align="center" align="center">
          </el-table-column>
          <el-table-column prop="updateDate" :label="$t('common.updateDate')" :show-overflow-tooltip="true"
            header-align="center" align="center">
          </el-table-column>
          <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
            <template slot-scope="scope">
              <el-button v-if="$hasPermission('msg:msgWechatTemplateRel:update')" type="text" size="small"
                @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
              <el-button v-if="$hasPermission('msg:msgWechatTemplateRel:delete')" type="text" size="small"
                @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
          layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
          @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- 弹窗, 新增 / 修改 -->
        <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      </div>
    </el-card>
  </div>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './msgWechatTemplateRel-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/msg/msgWechatTemplateRel/page',
        getDataListIsPage: true,
        deleteURL: '/msg/msgWechatTemplateRel',
        deleteIsBatch: true,
        exportURL: '/msg/msgWechatTemplateRel/export'
      },
      dataForm: {
        appId: ''
      }
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
